﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SettingPanel : MonoBehaviour
{
    public Button m_btnClose;

    public Button m_btnOn;
    public GameObject m_OnSelect;
    public Button m_btnOff;
    public GameObject m_OffSelect;

    public Button m_btnPrivacy;
    public Button m_btnTerm;
    
    // Start is called before the first frame update
    void Start()
    {
        bool ismute = AudioManager.Instance.OnGetMute();
        m_OnSelect.gameObject.SetActive(!ismute);
        m_OffSelect.gameObject.SetActive(ismute);
        
        m_btnClose.onClick.AddListener(() =>
        {
            AudioManager.Instance.OnPlayClick();
            this.gameObject.SetActive(false);
        });
        
        m_btnOn.onClick.AddListener(() =>
        {
            AudioManager.Instance.OnPlayClick();
            m_OnSelect.gameObject.SetActive(true);
            m_OffSelect.gameObject.SetActive(false);
            AudioManager.Instance.OnMute(false);
            AudioManager.Instance.OnSetLocalData();

        });
        m_btnOff.onClick.AddListener(() =>
        {
            AudioManager.Instance.OnPlayClick();
            m_OnSelect.gameObject.SetActive(false);
            m_OffSelect.gameObject.SetActive(true);
            AudioManager.Instance.OnMute(true);
            AudioManager.Instance.OnSetLocalData();
        });
        m_btnPrivacy.onClick.AddListener(() =>
        {
            AudioManager.Instance.OnPlayClick();
            Application.OpenURL("https://www.aphroditesupergames.info/protocol/Privacy_policy.html");
        });
        m_btnTerm.onClick.AddListener(() =>
        {
            AudioManager.Instance.OnPlayClick();
            Application.OpenURL("https://www.aphroditesupergames.info/protocol/Terms_of_service.html");
        });
    }
}
